function submitInfoForm(pageNum, sortOrder){
	if (pageNum == 'excel'){
            document.infoForm.exportReport.value = 'Y';
	} else {
            document.infoForm.pageNum.value = pageNum;
	}
	if (sortOrder != 'same'){
		document.infoForm.sortOrder.value = sortOrder;
		document.infoForm.pageNum.value = 1;
	}
	document.infoForm.submit();
}

function checkSavedFilter(){
	submitForm = false;
        if(document.FiltersCreated.idFilter.length == undefined){
            if(document.FiltersCreated.idFilter == undefined){
                alert("No filters created")
            } else {
                if (document.FiltersCreated.idFilter.checked){
                    submitForm = true;
                }
            }            
        } else {
            for ( i =0; i < document.FiltersCreated.idFilter.length; i++ ) {
                    if (document.FiltersCreated.idFilter[i].checked){
                            submitForm = true;
                    }
            }
        }
        if (submitForm) {
                document.FiltersCreated.submit();
        } else {
                alert("Please select a filter");
        }
}

function confirmDelete()
{
	elements = document.ReportElements.element.length;
	count = 0;
	if (elements == null){
		if (document.ReportElements.element.checked == true){
			count = 1;
		}
	} else {
		for (i=0; i<elements; i++){
			if (document.ReportElements.element[i].checked == true){
				count++; }
		}
	}
	if (count > 0){
		if(confirm('Are you sure to delete ' + count + ' records ?')){
			// set the action before submit
			document.ReportElements.reportAction.value = 'Delete';
			document.ReportElements.submit();
		}
	}else{
		alert("No elements selected");
	}
}

function inputChanged(divName, idReportElement){
	document.getElementById(divName).className = 'ChangeInput';
	if (document.ReportElements.modifiedElements.value.indexOf(idReportElement + " ") < 0){
		document.ReportElements.modifiedElements.value += idReportElement + " ";
	}
	MM_showHideLayers('UpdateElements','','show')
}

function restoreInput(divName){
	document.getElementById(divName).className = 'AfterChangeInput';
}

function resizeTextarea(divName, cols){
    document.getElementById(divName).rows = countLines(document.getElementById(divName).value, cols) +1;
}

function countLines(strtocount, cols) {
    var hard_lines = 1;
    var last = 0;
    while ( true ) {
        last = strtocount.indexOf("\n", last+1);
        hard_lines ++;
        if ( last == -1 ) break;
    }
    var soft_lines = Math.round(strtocount.length / (cols-1));
    var hard = eval("hard_lines  " + unescape("%3e") + "soft_lines;");
    if ( hard ) soft_lines = hard_lines;
    return soft_lines;
}

function updateElements(){
	document.ReportElements.reportAction.value = "Update";
	document.ReportElements.submit();
}

